
//
//  EmoticonAttachment.m
//  OSChina
//
//  Created by 8b410-2 on 17/1/7.
//  Copyright © 2017年 abb. All rights reserved.
//

#import "OSCEmoticonAttachment.h"
#import "NSString+Common.h"
@implementation OSCEmoticonAttachment

+ (NSAttributedString *)getEmoticonAttachmentWithEmoticon:(OSCEmoticon *)emoticon fontSize:(CGFloat)fontSize {
    // 创建附件
    OSCEmoticonAttachment *attachment = [OSCEmoticonAttachment new];
    attachment.chs = emoticon.chs;
    attachment.image = [UIImage imageNamed:emoticon.imageName];
    // TODO: - 判断是否是106-123的那几个emoji表情
    attachment.num = [emoticon.imageName isPureInt] ? : 0;
    // 设置附件大小
    attachment.bounds = CGRectMake(0, -4, fontSize, fontSize);
    
    return [NSAttributedString attributedStringWithAttachment:attachment];
}
- (BOOL)isPureInt:(NSString*)string{
    NSScanner* scan = [NSScanner scannerWithString:string];
    int val;
    return [scan scanInt:&val] && [scan isAtEnd];
}
@end
